"use strict";
cc._RF.push(module, '85351Tbo/dFqa+kfKLCkh4E', 'WeaponRocket');
// scripts/WeaponRocket.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("RocketItem"),
    s = t("GameConstant"),
    l = t("Util"),
    c = cc._decorator,
    d = c.ccclass,
    h = c.property,
    p = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.pfb_item = null, e.animation = null, e.rocket = null, e._gameControl = null, e._parent = null, e.isGameOver = !1, e.tagCollider = 0, e._damageNum = 0, e._carTag = 0, e.bCanAttack = !0, e;
  }

  return n(e, t), e.prototype.init = function (t, e, o, i, n, a) {
    this._gameControl = t, this._parent = e, this.tagCollider = o, this._damageNum = i, this._carTag = n, this._carTag == s.Collide_Car_Tag.Left ? (this.node.scaleX = 1, this.node.position = a) : (this.node.scaleX = -1, this.node.position = cc.v3(-a.x, a.y, a.z));
  }, e.prototype.playAnimation = function () {
    var t = this;
    this.bCanAttack && (this.isGameOver || (this.node.stopAllActions(), cc.tween(this.node).delay(l.Util.attackSpeed(.5, this._carTag)).call(function () {
      t.rocket.position = cc.v3(0, 0, 0), t.rocket.active = !0, t.animation.play(), t._gameControl.playSound(t._gameControl._audioControl.rocket_launch), t.createRocketItem();
    }).delay(l.Util.attackSpeed(.5, this._carTag)).call(function () {
      t.playAnimation();
    }).delay(.15).call(function () {}).start()));
  }, e.prototype.onGameStart = function () {}, e.prototype.onGameOver = function () {
    this.node.stopAllActions(), this.isGameOver = !0;
  }, e.prototype.onGameBoutReady = function () {
    this.node.active = !1, this.destroy();
  }, e.prototype.onGameBoutStart = function () {
    this.bCanAttack = !0, this.playAnimation();
  }, e.prototype.onGameBoutOver = function () {
    this.node.stopAllActions(), this.isGameOver = !0;
  }, e.prototype.onCanAttack = function (t) {
    this.bCanAttack = t, t ? this.playAnimation() : this.node.stopAllActions();
  }, e.prototype.createRocketItem = function () {
    var t = this;
    this.scheduleOnce(function () {
      t.rocket.active = !1;

      var e = t.rocket.convertToWorldSpaceAR(cc.v3(0, 0, 0)),
          o = t._gameControl._gameView.node.convertToNodeSpaceAR(e),
          i = t._parent.angle,
          n = 1;

      t._carTag == s.Collide_Car_Tag.Left ? n = t._gameControl._carLeftView.getScaleX() : t._carTag == s.Collide_Car_Tag.Right && (n = t._gameControl._carRightView.getScaleX());
      var a = cc.instantiate(t.pfb_item);
      a.getComponent(r["default"]).initItem(t.tagCollider, t._carTag, n, o, i), t._gameControl._gameView.node.addChild(a);
    }, l.Util.attackSpeed(.65, this._carTag));
  }, e.prototype.getDamage = function () {
    return l.Util.vibrateMiddle(), this._damageNum;
  }, a([h(cc.Prefab)], e.prototype, "pfb_item", void 0), a([h(cc.Animation)], e.prototype, "animation", void 0), a([h(cc.Node)], e.prototype, "rocket", void 0), a([d], e);
}(cc.Component);

o["default"] = p;

cc._RF.pop();